"use strict";
define(["jquery", "bootstrap", "backend", "table", "form", "upload", "vue", "vuedraggable"], function (e, t, a, n, i, o, r, l) {
    var p = {
        index: function () {
            n.api.init({
                extend: {
                    index_url: "wanlshop/page/index" + location.search,
                    add_url: "",
                    edit_url: "wanlshop/page/edit",
                    del_url: "wanlshop/page/del",
                    multi_url: "",
                    table: "wanlshop_page"
                }
            }), Fast.config.openArea = ["90%", "90%"];
            var t = e("#table");
            t.bootstrapTable({
                url: e.fn.bootstrapTable.defaults.extend.index_url,
                pk: "id",
                sortName: "id",
                columns: [[{checkbox: !0}, {field: "id", title: __("Id")}, {
                    field: "page_token",
                    title: __("Token")
                }, {field: "name", title: __("Name")}, {field: "shop_id", title: __("Shop_id")}, {
                    field: "type",
                    title: __("Type"),
                    searchList: {page: __("Page"), shop: __("Shop"), index: __("Index")},
                    formatter: n.api.formatter.normal
                }, {
                    field: "createtime",
                    title: __("Createtime"),
                    operate: "RANGE",
                    addclass: "datetimerange",
                    formatter: n.api.formatter.datetime
                }, {
                    field: "updatetime",
                    title: __("Updatetime"),
                    operate: "RANGE",
                    addclass: "datetimerange",
                    formatter: n.api.formatter.datetime
                }, {
                    field: "status",
                    title: __("Status"),
                    searchList: {normal: __("Normal"), hidden: __("Hidden")},
                    formatter: n.api.formatter.status
                }, {
                    field: "operate",
                    title: __("Operate"),
                    table: t,
                    events: n.api.events.operate,
                    formatter: n.api.formatter.operate
                }]]
            }), n.api.bindevent(t), e(document).on("click", ".btn-addnew", function () {
                a.api.open("wanlshop/page/add/", __("新建页面"), {area: ["800px", "400px"]})
            })
        }, recyclebin: function () {
            n.api.init({extend: {dragsort_url: ""}});
            var t = e("#table");
            t.bootstrapTable({
                url: "wanlshop/page/recyclebin" + location.search,
                pk: "id",
                sortName: "id",
                columns: [[{checkbox: !0}, {field: "id", title: __("Id")}, {
                    field: "type",
                    title: __("Type"),
                    align: "left",
                    searchList: {page: __("Page"), shop: __("Shop"), index: __("Index")},
                    formatter: n.api.formatter.normal
                }, {field: "shop_id", title: __("Shop_id"), align: "left"}, {
                    field: "name",
                    title: __("Name"),
                    align: "left"
                }, {field: "page_token", title: __("Token"), align: "left"}, {
                    field: "deletetime",
                    title: __("Deletetime"),
                    operate: "RANGE",
                    addclass: "datetimerange",
                    formatter: n.api.formatter.datetime
                }, {
                    field: "operate",
                    width: "130px",
                    title: __("Operate"),
                    table: t,
                    events: n.api.events.operate,
                    buttons: [{
                        name: "Restore",
                        text: __("Restore"),
                        classname: "btn btn-xs btn-info btn-ajax btn-restoreit",
                        icon: "fa fa-rotate-left",
                        url: "wanlshop/page/restore",
                        refresh: !0
                    }, {
                        name: "Destroy",
                        text: __("Destroy"),
                        classname: "btn btn-xs btn-danger btn-ajax btn-destroyit",
                        icon: "fa fa-times",
                        url: "wanlshop/page/destroy",
                        refresh: !0
                    }],
                    formatter: n.api.formatter.operate
                }]]
            }), n.api.bindevent(t)
        }, link: function () {
            n.api.init({extend: {index_url: "wanlshop/page/link"}});
            var t = [], i = e("#table");
            i.on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table", function (a, n) {
                "check" == a.type || "uncheck" == a.type ? n = [n] : t = [], e.each(n, function (e, n) {
                    if (a.type.indexOf("uncheck") > -1) {
                        var i = t.indexOf(n.route);
                        i > -1 && t.splice(i, 1)
                    } else -1 == t.indexOf(n.route) && t.push(n.route)
                })
            }), i.bootstrapTable({
                url: e.fn.bootstrapTable.defaults.extend.index_url,
                sortName: "id",
                pagination: !1,
                search: !1,
                showToggle: !1,
                showExport: !1,
                columns: [[{checkbox: !0}, {
                    field: "image",
                    title: __("Image"),
                    events: n.api.events.image,
                    formatter: n.api.formatter.image
                }, {field: "title", title: __("Title"), formatter: p.api.formatter.escape2Html}, {
                    field: "route",
                    title: __("Route"),
                    operate: !1
                }, {
                    field: "sort",
                    title: __("Sort"),
                    searchList: {product: __("Sort product"), brand: __("Sort brand"),sort: __("Sort sort"), page: __("Sort page")},
                    formatter: n.api.formatter.normal
                }, {
                    field: "operate", title: __("Operate"), events: {
                        "click .btn-chooseone": function (e, t, n, i) {
                            var o = a.api.query("multiple");
                            o = "true" == o, Fast.api.close({url: n.route, multiple: o})
                        }
                    }, formatter: function () {
                        return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __("Choose") + "</a>"
                    }
                }]]
            }), e(document).on("click", ".btn-choose-multi", function () {
                var e = a.api.query("multiple");
                e = "true" == e, Fast.api.close({url: t.join(","), multiple: e})
            }), n.api.bindevent(i)
        }, add: function () {
            p.api.bindevent()
        }, edit: function () {
            var e = new r({
                el: "#app", components: {wanldraggable: l}, data: function () {
                    return {
                        moduleStyle: {
                            height: {name: "高度（px）", default: "100px"},
                            width: {name: "宽度（%）", default: "100%"},
                            "background-image": {name: "背景图片（绝对路径）", default: "url(..图片地址..)"},
                            "background-color": {name: "背景颜色（HEX）", default: "#ffffff"},
                            "background-repeat": {name: "背景重复方式", default: ""},
                            color: {name: "字体颜色", default: "#333333"},
                            "font-size": {name: "字体大小（px）", default: "12px"},
                            "text-align": {name: "对齐方式", default: "inherit"},
                            "line-height": {name: "段落高度（px）", default: ""},
                            border: {name: "边框", default: "1px solid #000000"},
                            "border-bottom": {name: "下边框", default: "1px solid #000000"},
                            "border-left": {name: "左边框", default: "1px solid #000000"},
                            "border-right": {name: "右边框", default: "1px solid #000000"},
                            "border-top": {name: "上边框", default: "1px solid #000000"},
                            "border-radius": {name: "圆角（px）", default: "10px"},
                            margin: {name: "外边距", default: "25px"},
                            "margin-bottom": {name: "下外边（px）", default: "25px"},
                            "margin-right": {name: "右外边（px）", default: "25px"},
                            "margin-left": {name: "左外边（px）", default: "25px"},
                            "margin-top": {name: "上外边（px）", default: "25px"},
                            padding: {name: "内边距", default: "25px"},
                            "padding-bottom": {name: "下内边（px）", default: "25px"},
                            "padding-left": {name: "左内边（px）", default: "25px"},
                            "padding-right": {name: "右内边（px）", default: "25px"},
                            "padding-top": {name: "上内边（px）", default: "25px"}
                        },
                        module: {
                            Basics: [{
                                name: "轮播组件",
                                type: "banner",
                                style: {color: "#000000"},
                                params: {interval: "2800", banstyle: "圆形"},
                                data: [{
                                    image: "/assets/addons/wanlshop/img/page/banner-default.png",
                                    tips: "尽量使用高像素素材，否则可能出现虚化",
                                    link: ""
                                }]
                            }, {
                                name: "图片组件",
                                type: "image",
                                style: {height: "100px", width: "100%"},
                                data: [{
                                    image: "/assets/addons/wanlshop/img/page/image-default.png",
                                    tips: "尽量使用高像素素材，否则可能出现虚化",
                                    link: ""
                                }]
                            }, {
                                name: "视频组件",
                                type: "video",
                                style: {},
                                data: [{image: "/assets/addons/wanlshop/img/page/video-default.png", video: ""}]
                            }, {
                                name: "菜单组件",
                                type: "menu",
                                params: {
                                    colfive: "5",
                                    menuMarginTop: "12.5px",
                                    menuMarginBottom: "5px",
                                    menuHeightWidth: "45px",
                                    menuIconSize: "28px",
                                    menuTextSize: "12px"
                                },
                                style: {color: "#333333", "padding-bottom": "12.5px"},
                                data: [{
                                    "text": "菜单一",
                                    "text_en": "Menu 1",
                                    icon: "wlIcon-leimu",
                                    iconClass: "wanl-text-white",
                                    bgClass: "wanl-bg-redorange",
                                    link: ""
                                }]
                            }, {
                                "name": "自定义菜单组件",
                                "type": "custommenu",
                                "params": {
                                    "colfive": "5",
                                    "menuMarginTop": "12.5px",
                                    "menuMarginBottom": "5px",
                                    "menuHeightWidth": "45px",
                                    "menuIconSize": "28px",
                                    "menuTextSize": "12px"
                                },
                                "style": {
                                    "color": "#333333",
                                    "padding-bottom": "12.5px"
                                },
                                "data": [{
                                    "text": "菜单一",
                                    "text_en": "Menu 1",
                                    "image": "/assets/addons/wanlshop/img/page/article-default.png",
                                    "link": ""
                                }]
                            },{
                                name: "公告栏",
                                type: "notice",
                                params: {show: !0},
                                style: {"background-color": "#fffbe8", color: "#de8f1c", padding: "2px 12.5px"},
                                data: [{
                                    content: "公告内容",
                                    content_en: "公告内容",
                                    link: ""
                                }]
                            }, {
                                name: "搜索栏",
                                type: "search",
                                params: {searchRadius: "2000px", searchBackground: "#eee", searchPadding: "6px 15px"},
                                style: {padding: "12.5px"},
                                data: [{
                                    content: "关键字请用空格 隔开",
                                    content_en: "关键字请用空格 隔开",
                                }]
                            }],
                            Shop: [/*{
                                name: "活动橱窗",
                                type: "activity",
                                style: {"background-color": "#ffffff", "border-radius": "10px", margin: "12.5px"},
                                data: [{
                                    activity: "rush",
                                    textColor: "wanl-pip",
                                    describe: "30天包退 365天包换",
                                    tags: "新品尝鲜",
                                    title: "自动获取商品"
                                }]
                            },*/ {
                                name: "类目标题",
                                type: "categoryTitle",
                                style: {margin: "12.5px", color: "#ffffff"},
                                data: [{
                                    categoryName: "默认名",
                                    icon: "wlIcon-huomiao2",
                                    categoryLink: ""
                                }]
                            }, {
                                name: "分类橱窗",
                                type: "classify",
                                style: {"background-color": "#ffffff", "border-radius": "10px", margin: "12.5px"},
                                params: {colStyle: "col-2-2-4"},
                                data: [{categoryId: 1, textColor: "wanl-pip", describe: "30天包退 365天包换", tags: "新品尝鲜"}]
                            }, {
                                name: "商品组件",
                                type: "goods",
                                style: {"background-color": "#f5f5f5"},
                                params: {colthree: "2", colmargin: "25"},
                                data: [{goodsLink: 1}]
                            }],
                            Tool: [{name: "空白行", type: "empty", style: {height: "25px"}, data: []}, {
                                name: "分隔符",
                                type: "division",
                                style: {width: "100%", padding: "12.5px"},
                                params: {
                                    lineWidth: "60%",
                                    lineHeight: "1px",
                                    lineBackground: "#bababa",
                                    lineText: "文字内容",
                                    lineText_en: "Content",
                                    lineTextColor: "#333333",
                                    lineTextSize: "14px",
                                    lineTextBackground: "#ffffff",
                                    lineTextPadding: "0 9px"
                                }
                            }]
                        },
                        pageData: Config.page,
                        pageRecover: Config.pageRecover,
                        pageCategory: Config.pageCategory,
                        type: "page",
                        device: "iPhoneX",
                        nowTime: "11:11",
                        signal: "WIFI",
                        moveDom: "",
                        changeDom: "",
                        startY: 0,
                        endY: 0
                    }
                }, created: function () {
                    this.nowTimes()
                }, mounted: function () {
                    this.nowTimes()
                }, filters: {
                    formatDate: function (e) {
                        var t = new Date(1e3 * e);
                        return t.getFullYear() + "-" + (t.getMonth() + 1 < 10 ? "0" + (t.getMonth() + 1) : t.getMonth() + 1) + "-" + t.getDate() + " " + t.getHours() + ":" + t.getMinutes() + ":" + t.getSeconds()
                    }
                }, methods: {
                    publish: function () {
                        var e = this;
                        Fast.api.ajax({url: "wanlshop/page/edit", data: this.pageData}, function (t, a) {
                            e.pageRecover = t, parent.$("a.btn-refresh").trigger("click")
                        })
                    }, recover: function (e) {
                        var t = this;
                        Fast.api.ajax({url: "wanlshop/page/recover", data: {id: e}}, function (e, a) {
                            t.pageData = e
                        })
                    }, onType: function (e) {
                        this.type = e
                    }, addData: function (t, a) {
                        r.set(e.pageData.item[t].data, e.pageData.item[t].data.length, JSON.parse(JSON.stringify(a)))
                    }, delData: function (t, a) {
                        1 == e.pageData.item[t].data.length ? Toastr.warning("不能再删了，至少剩一个") : r.delete(e.pageData.item[t].data, a)
                    }, addStyle: function (t, a, n) {
                        r.set(e.pageData.item[t].style, a, n)
                    }, delStyle: function (t, a) {
                        r.delete(e.pageData.item[t].style, a)
                    }, delModule: function (t) {
                        r.delete(e.pageData.item, t), this.type = this.type - 1
                    }, onDevice: function (e) {
                        this.device = e
                    }, onSignal: function (e) {
                        this.signal = e
                    }, addTemplate: function (e) {
                        this.type = this.pageData.item.length, r.set(this.pageData.item, this.pageData.item.length, JSON.parse(JSON.stringify(e)))
                    }, changeImage: function (t, a) {
                        var n = t.target.files[0], i = new FormData;
                        i.append("file", n, n.name), Fast.api.ajax({
                            url: "ajax/upload",
                            data: i,
                            processData: !1,
                            contentType: !1
                        }, function (t, n) {
                            r.set(e.pageData.page.style, a, t.fullurl)
                        })
                    }, dataUpload: function (t, a, n, i) {
                        var o = t.target.files[0], l = new FormData;
                        l.append("file", o, o.name), Fast.api.ajax({
                            url: "ajax/upload",
                            data: l,
                            processData: !1,
                            contentType: !1
                        }, function (t, o) {
                            r.set(e.pageData.item[a].data[n], i, t.fullurl)
                        })
                    }, obtainLink: function (t, a, n, i) {
                        parent.Fast.api.open("wanlshop/page/link?multiple=" + i, __("选择链接"), {
                            area: ["800px", "600px"],
                            callback: function (i) {
                                r.set(e.pageData.item[t].data[a], n, i.url)
                            }
                        })
                    }, attachmentLink: function (t, a, n, i) {
                        parent.Fast.api.open("wanlshop/attachment/select?mimetype=video/*&multiple=" + i, __("选择链接"), {
                            area: ["800px", "600px"],
                            callback: function (i) {
                                console.log(i), r.set(e.pageData.item[t].data[a], n, i.url)
                            }
                        })
                    }, categoryLink: function (t, a, n) {
                        parent.Fast.api.open("wanlshop/shopsort/select?multiple=" + n, __("选择类目链接"), {
                            area: ["800px", "600px"],
                            callback: function (n) {
                                r.set(e.pageData.item[t].data[a], "categoryLink", n.url), r.set(e.pageData.item[t].data[a], "categoryName", n.name)
                            }
                        })
                    }, goodsLink: function (t, a, n, i) {
                        parent.Fast.api.open("wanlshop/goods/select?multiple=" + i, __("选择商品链接"), {
                            area: ["800px", "600px"],
                            callback: function (i) {
                                r.set(e.pageData.item[t].data[a], n, i.url)
                            }
                        })
                    }, iconLink: function (t, a, n, i) {
                        parent.Fast.api.open("wanlshop/icon/select?multiple=" + i, __("选择图标"), {
                            area: ["800px", "600px"],
                            callback: function (i) {
                                r.set(e.pageData.item[t].data[a], n, i.name)
                            }
                        })
                    }, timeFormate: function (e) {
                        var t = new Date(e).getHours() < 10 ? "0" + new Date(e).getHours() : new Date(e).getHours(),
                            a = new Date(e).getMinutes() < 10 ? "0" + new Date(e).getMinutes() : new Date(e).getMinutes();
                        this.nowTime = t + ":" + a
                    }, nowTimes: function () {
                        this.timeFormate(new Date), setInterval(this.nowTimes, 5e4)
                    }, cdnurl: function (e) {
                        return Fast.api.cdnurl(e)
                    }, mergeSpace: function (e) {
                        return e = e.replace(/(\s|&nbsp;)+/g, "")
                    }, categoryName: function (e) {
                        var t = this.pageCategory, a = t[t.map(function (e) {
                            return e.id
                        }).indexOf(parseInt(e))];
                        if (a) return a.name
                    }, getListNum: function (e, t) {
                        return {
                            "col-1-2-2": [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
                            "col-1-1_2": [3, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
                            "col-2-1_2": [2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
                            "col-2-2_1": [2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
                            "col-2-2-1_2": [2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
                            "col-2-4": [2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
                            "col-2-2-4": [2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
                        }[e][t]
                    }, getParameter: function (e) {
                        var t = {
                            Basics: "基础组件",
                            Shop: "商城组件",
                            Tool: "辅助组件",
                            Advert: "广告组件",
                            interval: "轮播速度（毫秒）",
                            menuMarginTop: "图标-上边距",
                            menuMarginBottom: "图标-下边距",
                            menuHeightWidth: "圆形大小",
                            menuIconSize: "图标大小",
                            menuTextSize: "文字大小",
                            searchPadding: "搜索文字边距",
                            lineWidth: "线段长度",
                            lineHeight: "线段高度",
                            lineText: "文字内容",
                            lineText_en: "英文文字内容",
                            lineTextSize: "文字大小",
                            lineTextPadding: "文字外边距",
                            text: "名称",
                            describe: "描述",
                            tags: "标签",
                            distribution: "分销",
                            group: "团购拼团",
                            bargain: "砍价",
                            rush: "限时抢购",
                            coupon: "领券中心",
                            text_en : '英文名称',
                            content_en : '英文内容',
                        };
                        return t.hasOwnProperty(e) ? t[e] : e
                    }
                }
            })
        }, api: {
            formatter: {
                escape2Html: function (e, t, a) {
                    return e.toString().replace(/(&|&amp;)nbsp;/g, "")
                }
            }, bindevent: function () {
                i.api.bindevent(e("form[role=form]"))
            }
        }
    };
    return p
});